package com.frx.datastruct.chaptereight;

import java.util.ArrayList;
import java.util.Random;

/**
 * Created by xurenfeng on 2019/3/6.
 */
public class MainTest {

    public static void main(String[] args){
        int n = 10000;
        Random random = new Random();
        MaxHeap<Integer> maxHeap = new MaxHeap<>();
        for (int i = 0; i < n ; i++){
            maxHeap.add(random.nextInt(Integer.MAX_VALUE));
        }

        ArrayList<Integer> list = new ArrayList<>(n);
        for (int i = 0; i<n;i++){
            list.add(maxHeap.extractMax());
        }

        for (int i = 1; i< list.size();i++){
            if (list.get(i-1) < list.get(i)){
                throw new IllegalArgumentException("maxHeap error");
            }
        }
        System.out.println("heapSort success !");

    }
}
